<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>


    <style>
        nav {
            top: 0;
            background-color: rebeccapurple;
            position:sticky;
        }

        .container {
            overflow: auto;
            width: 200px;
            height: 200px;
        }
    </style>
</head>

<body>
    <div class="container">
        <div>
        <nav>23123123</nav>
        34er234234234234
        34er234234234234
        34er234234234234
        34er234234234234
        34er234234234234
        34er234234234234
        34er234234234234
        34er234234234234
        34er234234234234
        34er234234234234
        34er234234234234
        34er234234234234
        34er234234234234
        34er234234234234
        34er234234234234
        34er234234234234
        34er234234234234
        34er234234234234
        34er234234234234
        34er234234234234
        34er234234234234
        34er234234234234
        34er234234234234
        34er234234234234
        34er234234234234
        34er234234234234
        34er234234234234
        34er234234234234
        34er234234234234
        34er234234234234
        34er234234234234
        34er234234234234
        34er234234234234
        34er234234234234
        34er234234234234
        34er234234234234
        34er234234234234
        34er234234234234
        34er234234234234
        34er234234234234
        34er234234234234
    </div>
    <div>
        <!-- <nav>111111</nav> -->
        34er234234234234
        34er234234234234
        34er234234234234
        34er234234234234
        34er234234234234
        34er234234234234
        34er234234234234
        34er234234234234
        34er234234234234
        34er234234234234
        34er234234234234
        34er234234234234
        34er234234234234
        34er234234234234
        34er234234234234
        34er234234234234
        34er234234234234
        34er234234234234
        34er234234234234
        34er234234234234
        34er234234234234
        34er234234234234
        34er234234234234
        34er234234234234
        34er234234234234
        34er234234234234
        34er234234234234
        34er234234234234
        34er234234234234
        34er234234234234
        34er234234234234
        34er234234234234
        34er234234234234
        34er234234234234
        34er234234234234
        34er234234234234
        34er234234234234
        34er234234234234
    </div>
</div>
</body>

</html>